<template>
    <el-drawer v-model="visible" :with-header="false" :size="800" destroy-on-close @closed="handleClose">
        <el-container v-loading="loading">
            <el-main style="padding:20px 20px 20px 20px" class="">
                <el-container class="is-vertical">
                    <sc-title title="申请详情"></sc-title>
                    <div>
                        <el-tabs v-model="activeName">
                            <el-tab-pane label="基本信息" name="first">
                                <el-form ref="form" label-width="110px" class="formshows" label-position="right" size="small">
                                    <div class="info">
                                        <el-row>
                                            <el-col :span="24">
												<el-row>
													<el-col :span="12">
                                                        <el-form-item label="头像:">
                                                            <el-image contain style="width: 60px; height: 60px" :src="info.portrait.url" :preview-src-list="[info.portrait.url]" v-if="info.portrait"></el-image>
														</el-form-item>
                                                    </el-col>
												</el-row>
                                                <el-row>
                                                    <el-col :span="12">
                                                        <el-form-item label="姓名:">{{info.name}}</el-form-item>
                                                        <el-form-item label="生日:">{{info.birthday}}</el-form-item>
                                                        <el-form-item label="等级:">{{info.level && info.level.name}}</el-form-item>
                                                        <el-form-item label="状态:">
                                                            <el-tag size="mini" v-if="info.status && info.status.value == 0" type="warning">{{ info.status.name }}</el-tag>
                                                            <el-tag size="mini" v-if="info.status && info.status.value == 1" type="success">{{ info.status.name }}</el-tag>
                                                            <el-tag size="mini" v-if="info.status && info.status.value == 2" type="danger">{{ info.status.name }}
                                                                <template v-if="info.status.remark">
                                                                    <el-tooltip class="box-item" effect="dark" :content="info.status.remark" placement="top-end">
                                                                        <i style="cursor: pointer" class="el-icon-question table-msg" />
                                                                    </el-tooltip>
                                                                </template>
                                                            </el-tag>
                                                        </el-form-item>
                                                        <el-form-item label="推荐人:">{{info.recommender || '无'}}</el-form-item>
                                                        <el-form-item label="所属机构:">{{info.agent && info.agent.name}}</el-form-item>
                                                        <el-form-item label="银行卡号:">{{info.bankCode}}</el-form-item>
                                                    </el-col>
                                                    <el-col :span="12">
                                                        <el-form-item label="手机:">{{info.mobile}}</el-form-item>
                                                        <el-form-item label="性别:">{{info.gender && info.gender.name}}</el-form-item>
                                                        <el-form-item label="头衔:">{{info.title && info.title.name}}</el-form-item>
                                                        <el-form-item label="开户人姓名:">{{info.bankUserName}}</el-form-item>
                                                        <el-form-item label="开户银行全称:">{{info.bankFullName}}</el-form-item>
                                                        <el-form-item label="申请时间:">
                                                           {{info.createdAt}}
                                                        </el-form-item>
                                                    </el-col>
                                                </el-row>
                                            </el-col>
                                        </el-row>
                                    </div>

                                    <div class="info">
                                        <div class="title">身份证照片</div>
                                        <div class="sc-upload-list" v-if="info.idCardImg && info.idCardImg.length > 0">
                                            <ul>
                                                <li v-for="(file, index) in info.idCardImg" :key="index">
                                                    <div class="sc-upload-item">
                                                        <el-image class="image" :src="file.url" fit="cover" :preview-src-list="previewIdCardImgs" hide-on-click-modal append-to-body :z-index="3500">
                                                            <template #placeholder>
                                                                <div class="image-slot">
                                                                    <i class="el-icon-more"></i>
                                                                </div>
                                                            </template>
                                                        </el-image>
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                        <el-empty v-else description="暂无身份证照片" :image-size="40" style="padding:0px;"></el-empty>
                                    </div>

                                </el-form>
                            </el-tab-pane>

                        </el-tabs>
                    </div>
                </el-container>
            </el-main>
            <el-footer>
                <el-button @click="visible=false">关闭</el-button>
            </el-footer>
        </el-container>
    </el-drawer>

</template>

<script>
import { in_array } from '@/utils/index.js'
export default {
    components: {
    },
    data() {
        return {
            in_array,
            visible: false,
            loading: false,
            qbLoading: false,
            dialog: {
                audit: false
            },
            activeName: 'first',
            info: this.getDefaultRuleForm(),
            teacherAuditId: null,
            previewIdCardImgs: [],
        }
    },
    methods: {
        open(id, active) {
            this.visible = true
            this.teacherAuditId = id
            if (active) {
                this.activeName = active
            }
            this.getData(id)
        },
        upLoginSearch() {
            this.$refs.loginTable.upData(this.loginTableSearch)
        },
        transactionSearchFun(){
            this.$refs.transactionTable.upData(this.transactionSearch)
        },
        async getData(id) {
            this.loading = true
            await this.$API.teacher.audit.action.get({id: id}).then((res) => {
                this.info = res.data
                if (res.data.idCardImg) {
                    res.data.idCardImg.forEach(item => {
                        item.path && this.previewIdCardImgs.push(item.url)
                    })
                }
                this.loading = false
            }, () => {
                this.loading = false
            })
        },
        handleSuccess() {
            this.open(this.info.id)
            this.$emit('success')
        },
        handleClose() {
            this.activeName = 'first'
            this.storeAuditId = null
        },
        expiryTime(row) {
            if (row.startTime && row.endTime) {
                return `${row.startTime} 至 ${row.endTime}`
            }
        },
        getDefaultRuleForm() {
            return {
                id: null,
                status: {}
            }
        }
    }
}
</script>

<style scoped>
.tcontainer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
}
.title {
    font-size: 14px;
    padding-left: 6px;
    font-weight: 500;
    padding-bottom: 20px;
}
.info {
    padding-bottom: 10px;
    margin-bottom: 10px;
}
.info:last-child {
    border: none;
    padding-bottom: 0;
    margin-bottom: 0;
}
[data-theme="dark"] .info {
    border-color: #434343;
}
:deep(.el-form-item__content) {
    font-size: 12px !important;
}
:deep(.el-image-viewer__close) {
    background-color: unset;
}
.el-form-item__label {
    text-align: justify;
}

.sc-upload-list {display: inline-block;}
.sc-upload-list li {list-style: none;display: inline-block;width: 120px;height: 120px;margin-right: 10px;vertical-align: top;box-sizing: border-box;}
</style>
